const mongoose = require('mongoose')

const banner = new mongoose.Schema({
    title: { type: String, required: true, minlength: 3, maxlength: 12 },
    img_url: { type: String, required: true },
    link: { type: String, default: 'http://www.qfedu.com/' },
    createTime: { type: Date, default: Date.now() }
})
const person = new mongoose.Schema({
    username: { type: String, required: true, minlength: 5, maxlength: 12 },
    password: { type: String, required: true, minlength: 5, maxlength: 12 },
    nickname: { type: String, required: true, minlength: 2, maxlength: 30 },
    age: { type: Number, default: 0 },
    gender: { type: String, enum: ['男', '女', '保密'], default: '保密' },
    desc: { type: String, maxlength: 200, default: '这个人很懒, 什么都没有留下 ! ^_^' },
    avatar: { type: String, default: '/public/avatar/default.webp' },
    is_status: { type: Boolean, default: true },
    createTime: { type: Date, default: Date.now() },
    cart: { type: Array, default: [] }
})
const goods = new mongoose.Schema({
    goods_id: { type: Number, required: true },
    title: { type: String, required: true },
    img_big_logo: { type: String },
    img_small_logo: { type: String},
    price: { type: String, required: true },
    current_price: { type: String,},
    is_select: { type: Boolean },
    goods_number: { type: Number,},
    is_sale: { type: Boolean },
    sale_type: { type: String, },
    is_hot: { type: Boolean },
    cart_number: { type: Number,},
    category: { type: String,}
})
module.exports = {
    BannerModel: mongoose.model('banner', banner),
    PersonModel: mongoose.model('person', person),
    GoodsModel: mongoose.model('goods', goods)
}